home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 3.2 / Ham Radio Version 3.2 (Chestnut CD-ROMs)(1993).ISO / fax / wefax / magsave.asm < prev    next >
Assembly Source File  |  1984-06-06  |  3KB  |  120 lines

  1. title        MAGSAVE.ASM ;derived from SAVEALL.ASM for use
  2. ;                    in MAGNIFY.BAS.
  3.  
  4. ;        by: e. w. schwittek    revised:6/6/84
  5.  
  6. page ,132
  7.  
  8. ;equates:
  9. aport        equ [0201h] ;game port
  10. sample_delay    equ 12
  11. line_delay    equ 576
  12.  
  13. data        segment
  14. fullbyte    db 0 ;sample collection byte
  15. count_4        db 4 ;4 samples of 2 bits each make fullbyte
  16. count_320    dw 320 ;bytes in each line of wefax picture
  17. count_64000    dw 64000 ;bytes used in one eseg
  18. sampl_delay_ctr    dw 0 ;set to sample_delay value after dec to 0
  19. data        ends
  20.  
  21. code        segment
  22. start        proc  far
  23.         assume ds:data,cs:code
  24.  
  25. ;save bp,es,ss and ds for return to basic program
  26.         push bp ;save bp
  27.         mov bp,sp ;get current stack position into bp
  28.         push es
  29.         push ss
  30.         push ds
  31.  
  32. ;gets value of "A" from basic as parameter
  33.         mov si,[bp]+6 ;get addr of para A into si
  34.         mov ax,[si] ;get value of para A
  35.         mov si,ax ;put para A into si for storage
  36.  
  37. ;establish addressability for data segment
  38.         mov ax,cs
  39.         add ax,si
  40.         add ax,10 ;diff between cs & ds
  41.         mov ds,ax
  42.  
  43.  
  44. ;initializes registers
  45.         mov ax,04000h ;first setting of es reg
  46.         mov es,ax
  47.         sub ax,ax
  48.         mov bx,0000h
  49.  
  50. ;sync start routine
  51.         mov cx,255
  52. sync_start:    mov dx,aport
  53.         in al,dx ;put aport into al
  54.         cmp al,64 ;carry flag at 0 if al=>64
  55.         jae sync_start ;jump on cf=0
  56.         loop sync_start
  57.  
  58. ;set counter for later use
  59.         mov cx,line_delay ;counts delay for line sync
  60.  
  61.  
  62. ;sample port and store two bits in fullbyte
  63. begin:        mov dx,aport
  64.         in al,dx ;put aport into al
  65.         rcl al,1 ;put bit 7 of aport in carry flag
  66.         rcl fullbyte,1 ;put carry flag in bit 0 of fullbyte
  67.         rcl al,1 ;put bit 6 of aport in carry flag
  68.         rcl fullbyte,1 ;put carry flag in bit 0 of fullbyte 
  69. ;        and move bit 0 to position 1
  70.  
  71. ;cause delay for proper sample rate
  72.         mov ax,sample_delay
  73.         mov sampl_delay_ctr,ax ;set-reset sampl delay ctr
  74. sample:        dec sampl_delay_ctr
  75.         jnz sample
  76.  
  77. ;fill fullbyte with 8 bits
  78.         dec count_4
  79.         jnz begin ;get another 2 bit sample
  80.         mov count_4,4 ;reset counter
  81.  
  82. ;establish fullbyte at proper memory location
  83.                 mov al,fullbyte
  84.         mov es:[bx],al ;fullbyte to 4000:0000
  85.         inc bx ;next fullbyte position
  86.         dec count_320
  87.         jz line_sync ;jumps when 320 byte line is complete
  88. continue:       dec count_64000 ;completes 1/4 pix
  89.         jnz begin
  90.         jmp reset
  91.  
  92. line_sync:    mov count_320,320 ;reset line byte counter
  93. wait:        nop
  94.         loop wait
  95.         mov cx,line_delay ;reset cx 
  96.         jmp continue
  97.  
  98. reset:        mov count_64000,64000 ;reset counter
  99.         mov bx,0 ;reset bx
  100.  
  101. ;change value of es reg
  102.         mov ax,es
  103.         add ax,01000h
  104.         mov es,ax
  105.  
  106. ;determine when es has had four values
  107.         cmp ax,07001h ;carry flag at 0 if ax =>7001h
  108.         jb begin
  109.  
  110. finish:        pop ds
  111.         pop ss
  112.         pop es
  113.  
  114.         mov sp,bp
  115.         pop bp ;restore stack
  116.                 ret 2 ;far return to basic
  117. start        endp
  118. code        ends
  119.         end
  120.